/**
 * @param {number} numRows
 * @return {number[][]}
*/
var generate = function(numRows) {
	if(numRows<1)return [];
    let result = [[1]];
    let cur = 1;
    while(cur<numRows){
    	result.push([1]);
    	for(let i=0;i<cur-1;i++){
    		let tmp = result[cur-1][i]+result[cur-1][i+1];
    		result[cur].push(tmp);
    	}
    	result[cur].push(1);
    	cur++;
    }
    return result;
}; 



console.log(generate(5));